<template>
  <el-form-item
    :label="i18nt('designer.setting.displayType')"
    v-if="selectedWidget.type === 'input'"
  >
    <el-select v-model="localOptionModel.type">
      <el-option label="text" value="text" />
      <!-- 当input的type设置为number时，如果输入非数字字符，则v-model拿到的值为空字符串，无法实现输入校验！故屏蔽之！！ -->
      <!--
      <el-option label="number" value="number"></el-option>
      -->
      <el-option label="password" value="password" />
    </el-select>
  </el-form-item>
</template>

<script>
import i18n from '@/utils/i18n'

export default {
  name: 'TypeEditor',
  mixins: [i18n],
  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object
  },
  data() {
    return {
      // Create a local copy of the prop to use with v-model
      localOptionModel: this.optionModel
    }
  },
  watch: {
    // Watch for changes in the local model and emit an event to update the parent component
    localOptionModel(newValue) {
      this.$emit('update:optionModel', this.localOptionModel)
    },

    // Also make sure to update the local model if the prop changes externally
    optionModel(newVal) {
      this.localOptionModel = newVal
    }
  }
}
</script>

<style lang="scss" scoped></style>
